home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple II Magazines (PO)
/
Nibble Volume 09, No. 12 (1988-12)(MicroSPARC)(Side A).zip
/
Nibble Volume 09, No. 12 (1988-12)(MicroSPARC)(Side A).po
/
HRCOMP.T.txt
< prev
next >
Wrap
Text File
|
1996-12-24
|
6KB
|
200 lines
**************************************************
* *
* HRCOMP Source Code *
* *
* by S. Scott Zimmerman *
* Copyright (c) 1988 *
* by MicroSPARC, Inc *
* Concord, MA 01742 *
* *
* The MicroSPARC Assembler *
* *
**************************************************
ORG $6000 ;Relocatable
**************************************************
* EQUates: *
**************************************************
ENDCOMP EQU $00 ;End addrs of compact
COMPSTRT EQU $02 ;Start addrs of compact
SCRNNUM EQU $06 ;0=HR pg 1; 32=HR pg 2
LENGTH EQU $08 ;Length compact file
SCREND EQU $19 ;Pntr last scrn byte+1
HRPTR EQU $1C ;Pntr to HR screen
COMPTR EQU $1E ;Pntr to compact pict
ENDBYT EQU $80 ;#$80 ends 'on' bytes
SCRN1 EQU $2000 ;HR pg 1 start
MAXLEN EQU 5000 ;Max length allowed
ENDSCRN EQU $3FF8 ;Last adrs of pg 1
**************************************************
* Define macros: *
**************************************************
INCHR MAC ;Increment HR scrn byte
INC HRPTR ;Go to next HR byte
BNE ]A
INC HRPTR+1
]A LDA HRPTR ;Past HR screen?
CMP SCREND ;Compare LOB
LDA HRPTR+1 ;Get HOB for compare
SBC SCREND+1 ;End of 16-bit compare
BCS :A ;Branch to here
EMC
INCCO MAC ;Increment compact byte
INC COMPTR ;Go to next compact byte
BNE ]A
INC COMPTR+1
]A LDA COMPTR ;Past max length?
CMP ENDCOMP ;Compare LOB
LDA COMPTR+1 ;Get HOB for compare
SBC ENDCOMP+1 ;End of 16-bit compare
BCS :A ;Branch to here
EMC
**************************************************
* Initialize program pointers: *
**************************************************
LDA #SCRN1 ;Set scrn pntr address
STA HRPTR ;LOB
CLC ;Prepare to add
LDA #SCRN1/ ;HOB
ADC SCRNNUM ;Add 32 if HR page 2
STA HRPTR+1
LDA #ENDSCRN ;Set end pointer
STA SCREND ;LOB
CLC ;Prepare to add
LDA #ENDSCRN/ ;HOB
ADC SCRNNUM ;Add 32 if HR page 2
STA SCREND+1
CLC ;Prepare to add
LDA #MAXLEN ;Get maximum length
ADC COMPTR ;Add compact address
STA ENDCOMP ;Save as end of compact
LDA #MAXLEN/ ;HOB
ADC COMPTR+1
STA ENDCOMP+1 ;Save HOB
LDA COMPTR ;Save compact address
STA COMPSTRT
LDA COMPTR+1
STA COMPSTRT+1
**************************************************
* Compact the Hi-Res picture: *
**************************************************
GETBYT LDY #0 ;Zero the index
LDA (HRPTR),Y ;Get HR screen byte
BEQ NODOT ;Nothing there
CMP #ENDBYT ;Not 0, is it $80?
BEQ NODOT ;Yes, so treat as blank
PHA ;Save HR screen byte
LDA HRPTR ;Adrs of this byte
STA (COMPTR),Y ;Save in compact pict
INCCO TOOLONG1 ;Increment compact byte
LDA HRPTR+1 ;Get HOB curr HR addrs
SEC ;Prepare to subtract
SBC SCRNNUM ;Subtract 32 if HR pg 2
STA (COMPTR),Y ;Save HOB
INCCO TOOLONG1 ;Increment compact byte
PLA ;Restore screen byte
STA (COMPTR),Y ;Store byte value
INCCO TOOLONG1 ;Increment compact byte
INCHR STLEN1 ;Increment HR byte
CLV ;To force branch
BVC DOTON ;Always branch
NODOT INCHR STLEN1 ;Increment HR byte
CLV ;To force branch
BVC GETBYT ;Always branch
**************************************************
* Relays (to avoid jumps for relocatability) *
**************************************************
TOOLONG1 CLV ;To force branch
BVC TOOLONG2 ;Always branch
STLEN1 CLV ;To force branch
BVC STLEN ;Always branch
GETBYT1 CLV ;To force branch
BVC GETBYT ;Always branch
**************************************************
* Check if next 4 bytes are zero: *
**************************************************
DOTON LDA (HRPTR),Y ;Get HR byte
INY ;Go to next HR byte
ORA (HRPTR),Y ;OR it with previous
INY ;Go to next HR byte
ORA (HRPTR),Y ;Or it with previous
INY ;Got to next HR byte
ORA (HRPTR),Y ;Or this also
BEQ CLEAR ;All are clear
CMP #ENDBYT ;Also check for $80
BEQ CLEAR ;No pixel on either
LDY #0 ;Go back to orig byte
LDA (HRPTR),Y ;Get it again
CMP #ENDBYT ;Is it $80?
BNE ADDON ;No, so add to table
LDA #0 ;Yes, convert to 0
ADDON STA (COMPTR),Y ;Save byte in compact
INCCO TOOLONG1 ;Increment compact
INCHR STLEN ;Increment HR byte
CLV ;To force branch
BVC DOTON ;Always branch
CLEAR LDY #0 ;Set index back to 0
LDA #ENDBYT ;Get end byte $80
STA (COMPTR),Y ; Store in table
INCCO TOOLONG ;Increment compact
INCHR STLEN ;Increment HR byte
CLV ;To force branch
BVC GETBYT1 ;Always branch
TOOLONG2 CLV ;Relay (relocatability)
BVC TOOLONG
**************************************************
* Calculate length of compact picture: *
**************************************************
STLEN SEC ;Prepare to subtract
LDA COMPTR ;Get current (end) adrs
SBC COMPSTRT ;Subtract starting adrs
STA LENGTH ;Save length LOB
LDA COMPTR+1 ;Do HOB
SBC COMPSTRT+1
STA LENGTH+1
LDA SCRNNUM ;Restore scrn number
STA HRPTR
LDY #0 ;Put three $80 at end
LDA #ENDBYT
STA (COMPTR),Y
INY
STA (COMPTR),Y
INY
STA (COMPTR),Y
LDA LENGTH ;Check if zero
ORA LENGTH+1
BNE ADD3 ;No, so add 3
RTS ;Yes, so end here
ADD3 CLC ;Add these 3 to length
LDA LENGTH
ADC #3
STA LENGTH
LDA LENGTH+1
ADC #0
STA LENGTH+1
QUIT RTS ;Done
TOOLONG LDA #0 ;Set length to 0...
STA LENGTH ; if compact picture
STA LENGTH+1 ; is too long
RTS ;Abort